<?php

namespace Drupal\shushengyuan\Schemas;

use Drupal\shusy_favorite_product\Entity\ShusyFavoriteProduct;

/**
 * @OA\Schema(
 *   schema="FavoriteProductItem",
 *   type="object",
 *   description="FavoriteProductItem"
 * )
 */
class FavoriteProductItem extends AbstractBaseModel {

  protected function getEntityType() {
    return 'shusy_favorite_product';
  }

  protected function setValue() {
    if ($this->entity instanceof ShusyFavoriteProduct) {
      $value = [
        /**
         * @OA\Property(
         *   property="id",
         *   type="integer",
         *   description="ID",
         * ),
         */
        'id' => (int) $this->entity->id,
        /**
         * @OA\Property(
         *   property="product",
         *   ref="#/components/schemas/ProductItem",
         *   description="产品信息",
         * ),
         */
        'product' => ProductItem::get($this->entity->product_id),
      ];
      $this->merge($value);
    }
  }
}
